1. Field of the Invention
This invention relates generally to computer generated images and more particularly to a method for computing the intensity of specularly reflected light.
2. Description of the Background Art
The illumination of a computer-generated object by colored light sources and ambient light is described by an illumination model. The illumination model is a mathematical expression including ambient, diffuse, and specular illumination terms. The object is illuminated by the reflection of ambient light and the reflection of light source light from the surface of the object. Therefore, the illumination of the object is composed of ambient, diffuse, and specularly reflected light. Given ambient light and light sources positioned about the object, the illumination model defines the reflection properties of the object. The illumination model is considered to be accurate if the illuminated object appears realistic to an observer. Typically, the illumination model is incorporated in a program executed by a rendering engine, a vector processing unit, or a central processing unit (CPU). The program must be capable of computing the illumination of the object when the light sources change position with respect to the object, or when the observer views the illuminated object from a different angle, or when the object is rotated. Furthermore, an efficient illumination model is needed for the program to compute the illumination in real-time, for example, if the object is rotating. Therefore, it is desired to incorporate terms in the illumination model that are computationally cost effective, while at the same time generating an image of the illuminated object that is aesthetically pleasing to the observer.
Ambient light is generalized lighting not attributable to direct light rays from a specific light source. In the physical world, for example, ambient light is generated in a room by multiple reflections of overhead florescent light by the walls and objects in the room, providing an omni-directional distribution of light. The illumination of the object by ambient light is a function of the color of the ambient light and the reflection properties of the object.
The illumination of the object by diffuse and specular light depends upon the colors of the light sources, positions of the light sources, the reflection properties of the object, the orientation of the object, and the position of the observer. Source light is reflected diffusely from a point on the object's surface when the surface is rough, scattering light in all directions. Typically, the surface is considered rough when the scale length of the surface roughness is approximately the same or greater than the wavelength of the source light. FIG. 1A illustrates diffuse reflection from an object's surface. A light ray i 105 from a source 110 is incident upon a surface 115 at point P 120, where a bold character denotes a vector. Light ray i 105 is scattered diffusely about point P 120 into a plurality of light rays r1 125, r2 125, r3 125, r4 125, and r5 125.
If the scale length of the surface roughness is much less than the wavelength of the source light, then the surface is considered smooth, and light is specularly reflected. Specularly reflected light is not scattered omni-directionally about a point on the object's surface, but instead is reflected in a preferred direction. FIG. 1B illustrates specular reflection from an object's surface. A light ray i 130 from a source 135 is incident upon a surface 140 at a point P 145. Light ray i 130 is specularly reflected about point P 145 into a plurality of light rays r1 150, r2 150, r3 150, r4 150, and r5 155, confined within a cone 160 subtended by angle φ 165. Light ray r 155 is the preferred direction for specular reflection. That is, the intensity of specularly reflected light has a maximum along light ray r 155. As discussed further below in conjunction with FIGS. 2A–2B, the direction of preferred light ray r 155 is specified when the angle of reflection is equal to the angle of incidence.
Typically, objects reflect light diffusely and specularly, and in order to generate a realistic illumination of the computer-generated object that closely resembles the real physical object, both diffuse and specular reflections need to be considered.
FIG. 2A illustrates specular reflection from an object's surface in a preferred direction, including a unit vector l 205 pointing towards a light source 210, a unit vector n 215 normal to a surface 220 at a point of reflection P 225, a unit vector r 230 pointing in the preferred reflected light direction, a unit vector v 235 pointing towards an observer 240, an angle of incidence θi 245 subtended by the unit vector l 205 and the unit vector n 215, an angle of reflection θr 250 subtended by unit vector n 215 and the unit vector r 230, and an angle θrv 255 subtended by unit vector r 230 and unit vector v 235. Light from the source 210 propagates in the direction of a unit vector −l 260, and is specularly reflected from the surface 220 at point P 225. A unit vector is a vector of unit magnitude.
Reflection of light from a perfectly smooth surface obeys Snell's law. Snell's law states that the angle of incidence θi 245 is equal to the angle of reflection θr 250. If surface 220 is a perfectly smooth surface, light from source 210 directed along the unit vector −l 260 at an angle of incidence θi 245 is reflected at point P 225 along unit vector r 230 at an angle of reflection θr 250, where θi=θr. Consequently, if surface 220 is a perfectly smooth surface, then light directed along −l 260 from source 210 and specularly reflected at point P 225 would not be detected by observer 240, since specularly reflected light is directed only along unit vector r 230. However, a surface is never perfectly smooth, and light directed along −l 260 from source 210 and specularly reflected at point P 225 has a distribution about unit vector r 230, where unit vector r 230 points in the preferred direction of specularly reflected light. The preferred direction is specified by equating the angle of incidence θi 245 with the angle of reflection θr 250. In other words, specular reflection intensity as measured by observer 240 is a function of angle θrv 255, having a maximum reflection intensity when θrv=0 and decreasing as θrv 255 increases. That is, observer 240 viewing point P 225 of the surface 220 detects a maximum in the specular reflection intensity when unit vector v 235 is co-linear with unit vector r 230, but as observer 240 changes position and angle θrv 235 increases, observer 240 detects decreasing specular reflection intensities.
A first prior art method for computing the intensity of specularly reflected light is to represent the specular intensity as f(r,v,n)∝(r·v)n, where 1≦n≦∞ and n is a parameter that describes the shininess of the object. Since r and v are unit vectors, the dot product r·v=cos θrv, and therefore, f(r,v,n)∝cosnθrv.
A second prior art method computes the intensity of specularly reflected light in an alternate manner. For example, FIG. 2B illustrates another embodiment of specular reflection from an object's surface in a preferred direction, including a unit vector l 265 pointing towards a light source 270, a unit vector n 275 normal to a surface 280 at a point of reflection P 282, a unit vector r 284 pointing in the preferred reflected light direction, a unit vector v 286 pointing towards an observer 288, a unit vector h 290 bisecting the angle subtended by the unit vector l 265 and the unit vector v 286, an angle of incidence θi 294, an angle of reflection θr 290, and an angle θnh 292 subtended by the unit vector h 290 and the unit vector n 275. Light from the source 270 propagates in the direction of a unit vector −l 272. The angle of incidence θi 294 is equal to the angle of reflection θr 290. The specular intensity is represented as g(n,h,n)∝(n·h)n, where 1≦n≦∞ and n is a parameter that describes the shininess of the object. Since n and h are unit vectors, the dot product n·h=cos θnh, and therefore, g(n,h,n)∝cosn θnh. When the surface 280 is rotated such that unit vector n 275 is co-linear with unit vector h 290, then cos θnh=1, the specular intensity g(n,h,n) is at a maximum, and therefore the observer 288 detects a maximum in the specularly reflected light intensity. The second prior art method for computing the intensity of specular reflection has an advantage over the first prior art method in that the second prior art method more closely agrees with empirical specular reflection data.
The first and second prior art methods for computing the intensity of specularly reflected light are computationally expensive compared to the calculation of the diffuse and ambient terms that make up the remainder of the illumination model. Specular intensity as defined by the prior art is proportional to cosn θ, where θ≡θrv or θ≡θnh. The exponential specular intensity function cosn θ can be evaluated for integer n, using n−1 repeated multiplications, but this is impractical since a typical value of n can easily exceed 100. If the exponent n is equal to a power of two, for example n=2m, then the specular intensity may be calculated by m successive squarings. However, the evaluation of specular intensity is still cost prohibitive. If n is not an integer, then the exponential and logarithm functions can be used, by evaluating cosn θ as e(n ln(cos θ)), but exponentiation is at least an order of magnitude slower than the operations required to compute the ambient and diffuse illumination terms.
A third prior art method of computing specular intensity is to replace the exponential specular intensity function with an alternate formula that invokes a similar visual impression of an illuminated object, however without exponentiation. Specular intensity is modeled by an algebraic function h(t,n)=t /(n−nt+t), where either t=cos θrv or t=cos θnh, and n is a parameter that describes the shininess of the object. The algebraic function h(t,n) does not include exponents, but does include multiplication, addition, subtraction, and division operators. These algebraic operations are usually less costly than exponentiation. However, while the computation time has been reduced, in many computer architectures division is still the slowest of these operations.
It would be useful to implement a cost effective method of calculating specular intensity that puts the computation of the specular term on a more even footing with the computation of the ambient and diffuse terms, while providing a model of specular reflection that is aesthetically pleasing to the observer.